/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.so.trening;

import domen.OpstiDomenskiObjekat;
import domen.Trening;
//import java.sql.SQLException;
//import java.util.logging.Level;
//import java.util.logging.Logger;
import server.baza.DataBaseBroker;
import server.so.OpstaSO;

/**
 *
 * @author Ivan Ivic
 */
public class KreirajTrening extends OpstaSO {
    public synchronized static int kreirajTrening(Trening trening)
    {
        KreirajTrening kt = new KreirajTrening();
        return kt.opsteIzvrsenjeSO(trening);
    }

    @Override
    public int izvrsenjeSO(OpstiDomenskiObjekat odo) {
        Trening trening = (Trening) odo;
        //Trening t = vratiTrening(trening);
        //if (t!=null)
            //return 0;
        signal = DataBaseBroker.getDbb().kreiraj(trening);  // 9011, 9012
        return signal;
        

    }

    @Override
    public boolean stanjeOperacije(int signal) {
        switch(signal)
        {
            case 9011:
                prikazi(signal, "Slog uspesno kreiran");
                return true;
            case 9012:
                prikazi(signal, "Slog nije uspesno kreiran");
                return false;
            case 9017:
                prikazi(signal, "Slog uspesno vracen");
                return true;
            case 9018:
                prikazi(signal, "Slog nije uspesno vracen");
                return false;
            default:
                return false;
        }
    }

    /*
    private Trening vratiTrening(Trening trening)
    {
        Trening t = new Trening();
        try {
            t = (Trening) DataBaseBroker.getDbb().vrati(trening);
            signal = 9017;            
        } catch (SQLException ex) {
            Logger.getLogger(KreirajTrening.class.getName()).log(Level.SEVERE, null, ex);
            signal = 9018;
            t = null;
        }
        return t;
    }
     * 
     */
     
     

}
